import UserAPI from "@/api/coupons";
import type { UserForm } from "@/api/user/model";
import type { IModalConfig } from "@/components/PageModal/index.vue";

const modalConfig: IModalConfig<UserForm> = {
  pageName: "sys:user",
  dialog: {
    title: "新增优惠券",
    width: 800,
    draggable: true,
  },
  form: {
    labelWidth: 100,
  },
  formAction: UserAPI.add,
  beforeSubmit(data) {
    console.log("提交之前处理", data);
  },
  formItems: [
    {
      label: "优惠码",
      prop: "code",
      rules: [{ required: true, message: "优惠码不能为空", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入优惠码",
      },
    },
    {
      label: "优惠金额",
      prop: "num",
      rules: [{ required: true, message: "优惠金额不能为空", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入优惠金额",
      },
    },
    {
      type: "select",
      label: "是否长期有效",
      prop: "isLongTerm",
      attrs: {
        placeholder: "请选择",
      },
      options: [
        { label: "是", value: '1' },
        { label: "否", value: '0' },
      ],
    },
    {
      type: "date-picker",
      label: "失效日期",
      prop: "expireDate",
      attrs: {
        placeholder: "请选择",
        valueFormat: 'YYYY-MM-DD'
      },
    },
  ],
};

export default modalConfig;
